package utils;

import java.text.DecimalFormat;
import java.text.NumberFormat;

public class FormatStyle {

	public static String customFormat(String pattern, double value) {
		NumberFormat myFormatter = new DecimalFormat(pattern);
		String output = myFormatter.format(value);
		return output;
	}

	public static String numberFormat(double value) {
		return customFormat("#.##", value);
	}

	public static String numberFormat(String sValue) {
		try {
			return customFormat("#.##", new Double(sValue).doubleValue());
		} catch (Exception ex) {
			ex.printStackTrace();
			return customFormat("#.####", 0);
		}
	}

	public static void main(String[] args) {
		System.out.println(FormatStyle.numberFormat("3.576679789"));
//		NumberFormat formatter = new DecimalFormat("#.######");
//	    String s = formatter.format("34.567"); 
//		System.out.println(s);
		
	}

}
